import request from './request'

// 员工数据类型
export interface EmployeeData {
  id: number
  employeeId: string
  name: string
  avatar: string
  department: string
  departmentId: number
  position: string
  positionId: number
  level: string
  phone: string
  email: string
  status: 'active' | 'inactive' | 'probation'
  joinDate: string
  workYears: number
  education: string
  school: string
  major: string
  graduationYear: string
  createTime: string
  updateTime: string
}

// 获取员工列表
export const getEmployeeList = () => {
  return request({
    url: '/employees/list',
    method: 'post',
    data: {}
  })
}

// 获取员工分页列表
export const getEmployeePage = (params: {
  current: number
  size: number
  name?: string
  keyword?: string
  departmentId?: number
  month?: string
  status?: string
}) => {
  return request({
    url: '/employees/page',
    method: 'post',
    data: params
  })
}

// 新增员工
export const addEmployee = (employee: Omit<EmployeeData, 'id' | 'createTime' | 'updateTime'>) => {
  return request({
    url: '/employees/add',
    method: 'post',
    data: employee
  })
}

// 编辑员工
export const updateEmployee = (employee: EmployeeData) => {
  return request({
    url: '/employees/update',
    method: 'post',
    data: employee
  })
}

// 删除员工
export const deleteEmployee = (id: number) => {
  return request({
    url: '/employees/delete',
    method: 'post',
    data: { id }
  })
}

// 切换员工状态
export const toggleEmployeeStatus = (id: number) => {
  return request({
    url: '/employees/toggle-status',
    method: 'post',
    data: { id }
  })
}

// 员工调岗
export const transferEmployee = (params: {
  id: number
  departmentId: number
  positionId: number
}) => {
  return request({
    url: '/employees/transfer',
    method: 'post',
    data: params
  })
}